
#ifndef CLIENTWIDGET_H
#define CLIENTWIDGET_H

#include <BLineEdit>
#include <BButton>
#include <BTcpServer>
#include <BTcpSocket>
#include <BMainWindow>

#include "LoginDialog.h"
#include "DialogListWidget.h"

class ClientWidget : public BWidget
{
public:
	ClientWidget();
	~ClientWidget();

	void setServerAddress(const BString& address);

protected:
	bool sendMessage();

protected:
	void slotConnectButtonClicked();
	void slotConnectButtonFrame(BObject* object);
	void slotLoginButtonClicked();
	void slotQuitButtonClicked();
	void slotInputEditKeyDown(BObject* object, const BValue& value);
	void slotSendButtonClicked();

	void slotSocketError();
	void slotSocketDisconnected(BObject* object, const BValue& value);
	void slotSocketReadyRead(BObject* object, const BValue& value);
	void slotSocketBytesSent(BObject* object, const BValue& value);

protected:
	virtual void updateEvent(const BEvent& event);
	virtual void styleEvent(const BEvent& event);
	virtual void paintEvent(const BEvent& event);

private:
	LoginDialog*		_loginWidget;
	BButton*			_connectButton;
	BButton*			_loginButton;
	BButton*			_quitButton;
	DialogListWidget*	_dialogList;
	BLineEdit*			_inputEdit;
	BButton*			_sendButton;
	BTcpSocket*			_socket;
	BBuffer				_buffer;
	BString				_serverAddress;
	BIconHolder			_serverIcon;
};

#endif